<script type="text/javascript" src="js/mainpage.js"></script>
<div class="ui-corner-all"><?php include "view/topmenu.php"; ?></div>
<div class="block">
	Welcome <?php 
		if(!empty($_SESSION['user'])){
			$user = $_SESSION['user'];
			echo $user->getName();
		}
	?>
</div>
<div class="block">
	<input type="hidden" id="pageid" value="1" />
<?php
	$school = $_SESSION['school'];
?>
	<!-- Description -->
	<fieldset>
		<legend><?php echo $school->getName(); ?></legend>
		<span id="spnSchoolDesc" name="spnSchoolDesc"><?php echo $school->getDescription(); ?></span>
		<?php HTMLUtil::EditButton("editSchoolDesc");  ?>
		<br/><br/>
		<small><b>President : </b> <span id="spnPresident"><?php echo $school->getPicname(); ?></span></small> <?php HTMLUtil::EditButton("editSchoolPic");  ?>
		<input type="hidden" id="schoolid" name="schoolid" value="<?php echo $school->getId(); ?>">
	</fieldset>
	<!-- Semester -->
	<fieldset>
		<legend>Current Semester</legend>
		<span id="semesterinfo">
			<?php
				if(empty($_REQUEST['currsemester'])){
					echo "Not defined";
				} else {
					echo $_REQUEST['currsemester']->getName() . " ("; 
					echo $_REQUEST['currsemester']->getFromdate() . " to "; 
					echo $_REQUEST['currsemester']->getTodate() . ")"; 
				}
			?>
		</span>	
			<!-- a href="#" id="edit_semester" class="ui-state-default ui-corner-all">Edit</a -->
			<?php HTMLUtil::EditButton("edit_semester"); ?>
		<div class="block">
			<?php HTMLUtil::AddButton("addNewSemester"); ?>
		</div>
	</fieldset>
	<!-- Notice -->
	<fieldset>
		<legend>Notice</legend>
		<div id="noticelist">
			<?php
				$notices = $_REQUEST['notices'];
				foreach($notices as $notice){
					echo "<span id=\"spnnotice" . $notice->getId() ."\">";
					echo "<b>" . $notice->getSubject() . "</b><br/><span>";
					echo $notice->getContent() . "</span> ";
					HTMLUtil::WriteActionButton("Edit", "editNotice('" . $notice->getId() . "')");
					echo " ";
					HTMLUtil::WriteActionButton("Delete", "deleteNotice('" . $notice->getId() . "')");
					echo "<hr></span>\n";
				}
			?>
		</div>
		<div class="block">
			<?php HTMLUtil::AddButton("addSchoolNotice"); ?>
		</div>
	</fieldset>
	<!-- Faculties -->
	<fieldset>
		<legend>Faculties</legend>
		<ul id="facultylist">
			<?php
				$faculties = $_REQUEST['faculties'];
				foreach($faculties as $faculty){
					echo "<li id=\"lifaculty" . $faculty->getId() . "\">";
					echo $faculty->getnAME() . " ";
					HTMLUtil::WriteActionButton("View", "viewFaculty('" . $faculty->getId() . "')");
					echo " ";
					HTMLUtil::WriteActionButton("Delete", "deleteFaculty('" . $faculty->getId() . "')");
					echo "</li>\n";
				}
			?>
		</ul>	
		<div class="block">
			<?php HTMLUtil::AddButton("addFaculty"); ?>
		</div>
	</fieldset>
	<div id="dialog" title="Current Semester">
		<p id="validateTips">All form fields are required.</p>
		<form>
		<fieldset style="text-align: right">
			<label for="name">Name</label>
			<input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" value="" />
			<label for="year">Year</label>
			<input type="text" name="year" id="year" value="" class="text ui-widget-content ui-corner-all" />
			<label for="fromdate">From</label>
			<input type="text" name="fromdate" id="fromdate" value="" class="text ui-widget-content ui-corner-all" />
			<label for="todate">To</label>
			<input type="text" name="todate" id="todate" value="" class="text ui-widget-content ui-corner-all" />
		</fieldset>
		<input type="hidden" name="semesterid" id="semesterid" value="" />
		</form>
	</div>
	<div id="dialog_school_desc" title="School Description">
		<textarea id="schooldesc" name="schooldesc" cols="50" rows="8" class="text ui-widget ui-corner-all"></textarea>
	</div>
	<div id="dialog_school_pic" title="President">
		<select id="selPresident"></select>
	</div>
	<div id="dialog_add_new_semester" title="New Semester">
		<p id="new_validateTips">All form fields are required.</p>
		<form>
			<fieldset style="text-align: right">
		<label for="new_name">Name</label>
		<input type="text" name="new_name" id="new_name" class="text ui-widget-content ui-corner-all" value="" />
		<label for="new_year">Year</label>
		<input type="text" name="new_year" id="new_year" value="" class="text ui-widget-content ui-corner-all" />
		<label for="new_fromdate">From</label>
		<input type="text" name="new_fromdate" id="new_fromdate" value="" class="text ui-widget-content ui-corner-all" />
		<label for="new_todate">To</label>
		<input type="text" name="new_todate" id="new_todate" value="" class="text ui-widget-content ui-corner-all" />
			</fieldset>
		</form>
	</div>
	<div id="dialog-newnotice" title="New Notice">
		<form>
			<fieldset>
				<label for="new_notice_subject">Subject</label>
				<input type="text" id="new_notice_subject" class="text ui-widget-content ui-corner-all"/>
				<textarea id="new_notice_content" cols="50" rows="8"></textarea>
			</fieldset>
		</form>
	</div>
	<div id="dialog_editnotice" title="Edit Notice">
		<form>
			<fieldset>
				<label for="edit_notice_subject">Subject</label>
				<input type="text" id="edit_notice_subject" class="text ui-widget-content ui-corner-all"/>
				<textarea id="edit_notice_content" cols="50" rows="8"></textarea>
				<input type="hidden" id="edit_notice_id" />
			</fieldset>
		</form>
	</div>
	<div id="dialog_new_faculty" title="New Faculty">
		<fieldset>
			<label for="faculty_name">Name</label>
			<input type="text" id="faculty_name"/><br>
			<label for="chairperson">Chairperson</label>
			<select id="chairperson"></select>
			<textarea id="facluty_description" cols="50" rows="8"></textarea>
		</fieldset>
	</div>
</div>
